<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>  
<%@ include file="/WEB-INF/views/taglibs.jsp" %>
<html>
<head> <meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body id="body">
<form id="form" action="update"  enctype="multipart/form-data" method="post">
<div class="dialogPage">
	<div class="om-panel-header">修改</div>
	<div class="editDiv">
		<table class="editTable">
		<tr>
			<td><span class="required">*</span>标题：</td>
			<td><input type="text" id="title" name="title" required="required" maxlength="50" value="${news.title}"></td>
			<td><span class="required">*</span>类型：</td>
			<td> <input id="type" name="type" type="combo" /></td>
		</tr>
		<tr>
			<td>描述：</td>
			<td colspan="3">
			<textarea name="remark" id="remark" cols="64" rows="3" maxlength="200">${news.remark}</textarea>
			</td>
		</tr>
		<tr>
	
	        <td><span class="required">*</span>图片：</td>
	        <td colspan="2">
				<input type="file" name="image" id="image" style="height: 30px;"/>
				<p style='color:red; font-size:12px;'>注：建议尺寸：320*320（png、jpg等格式，大小控制1M以内)</p>
			</td>
			<c:if test="${news.image != null}">
				<td>
					<img id="image" src="${news.image}" width="150" height="75" >
				</td>
			</c:if>
		</tr>
		<tr>
			<td>视频地址：</td>
			<td colspan="5">
			<input style="width:784px;" type="text" name="videoPath" id="videoPath" cols="128" rows="1" maxlength="200"  value="${news.videoPath}"/>
			</td>
		</tr>
	   </table>
	   <input id="status" type="hidden" name="status" />
	     <!-- 加载编辑器的容器 -->
        <script id="content"   name="content" type="text/plain" style="width:950px;height:200px; margin-left:20px;"></script>
   		<div class="editBtn" style="margin-top: 20px;">
			<button id ="btnSubmit" type="button" class="button" status="1">保存草稿</button>
			<button id ="btnPublish" type="button" class="button" status="2">发&nbsp;&nbsp;布</button>
			<button type="button" onclick="javascript:art.dialog.close();" class="button">&nbsp;关闭&nbsp;</button>
		</div>
	</div>
</div>
<input type="hidden" id="status" name="status">
<input type="hidden" name="id" value="${news.id}">
</form>
</body>
<script type="text/javascript">
var ue;
$(function(){
	  var v = "${news.type}";
	  
	  var data = JSON.parse('${typeCombo}');
	  if(v == ""){
		  v = data[0].value;
	  }
	  $('#type').combobox({  
	    	data:data,
	    	editable:false,
	    	value: v,
	    	panelHeight:'auto'
	    }); 
	 
	//初始化文本编辑器
	ue = UE.getEditor('content');
	
	//初始化内容
	ue.ready(function() {
	    //this是当前创建的编辑器实例
	    this.setContent('${news.content}')
	});
	
	$('#title').validatebox({
		required:true
		});
	
	$('#btnSubmit,#btnPublish').click(function(){
		if(!$("#form").form('validate')){return false;}
		var msgContent = ue.getContent();
		if (msgContent.length == 0) {
			alert("请输入详情");
			return false;
		}
		
		//获取状态
		$("#status").val($(this).attr("status"));
		
		$('#form').submit();
		
		$('#btnSubmit').attr({"disabled":"disabled"});
		
		$('#body').html("正在提交，请稍后。。");
		
	});
	
});
	
	

</script>
</html>